package com.heima.behavior.controller;

import com.heima.behavior.service.UserBehaviorService;
import com.heima.model.behavior.dtos.LikesBehaviorDto;
import com.heima.model.behavior.dtos.ReadBehaviorDto;
import com.heima.model.behavior.dtos.UnLikesBehaviorDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1")
@Slf4j
public class UserBehaviorController {

    @Autowired
    private UserBehaviorService userBehaviorService;

    /**
     * 用户点赞行为
     * @param dto
     * @return
     */
    @PostMapping("/likes_behavior")
    public ResponseResult handleLike(@RequestBody LikesBehaviorDto dto){
        return userBehaviorService.handleLike(dto);
    }

    /**
     * 用户阅读行为
     */
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDto dto){
        return userBehaviorService.handleRead(dto);
    }

    /**
     * 用户不喜欢行为
     * @param dto
     * @return
     */
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLikesBehavior(@RequestBody UnLikesBehaviorDto dto){
        return userBehaviorService.handleUnLike(dto);
    }



}
